import eps.einfacheGrafik.*;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Rectangle;
import java.awt.Color;

public class Screen extends Frame {

    private static final int SIZE = 400;
    private static final double xMin = 0.0;
    private static final double xMax = 20.0;
    private static final double yMin = 0.0;
    private static final double yMax = 20.0;
    private Rectangle rect;
    private Graphics2D g2 ;
    public Screen() {

        this.setSize(SIZE,SIZE);
        addWindowListener(new WindowAdapter(){  public void windowClosing(WindowEvent e) {  dispose();}});
    }

    public void paint(Graphics g) {
        zeicheKoordinatenSystem(g);
        rect = new Rectangle(150, 150, 50, 50);
        Graphics2D g2 = (Graphics2D)g;
    }

    private void zeicheKoordinatenSystem(Graphics g) {
        zeichneXAchse(g);
        zeichneYAchse(g);

    }

    private void zeichneXAchse(Graphics g) {
        for (int i = 0; i < xMax ; i++){
            int startx = berechneXPixel(xMin);
            int endx = berechneXPixel(xMax);
            int starty = berechneYPixel(i);
            int endy = berechneYPixel(i);
            g.drawLine(startx, starty, endx, endy);
        }
    }

    private void zeichneYAchse(Graphics g) {
        for (int i = 0; i < xMax ; i++){
            int startx = berechneXPixel(i);
            int endx = berechneXPixel(i);

            int starty = berechneYPixel(yMin);
            int endy = berechneYPixel(yMax);
            g.drawLine(startx, starty, endx, endy);

        }
    }

    public void RechtekTest(int x,int y,int width,int height){

        g2.fillRect(x,y,width,height);

    }

    public  void zeichneRechteck(int x1,int y1){
        int x=x1;
        int y=y1;
        int width=20;
        int height=20;
        //Hier soll die Farbe von g2 gesetzt werden
        g2.setColor(Color RED)
        g2.fillRect(x,y,width,height);
    }

    private int berechneXPixel(double x) {

        double pixelBreite = ((xMax - xMin) / (double)getWidth()); 
        return (int) ((x - xMin) / pixelBreite );
    }

    private int berechneYPixel(double y) {

        double pixelBreite = ((yMax - yMin) / (double)getHeight()); 
        return getHeight() - ((int) ((y - yMin) / pixelBreite));
    }

    public static void main(String[] args) {
        new Screen().setVisible(true);
    }

}